<?php
session_start();
require('../check_login.php');
include(dirname(__FILE__) . '/../config.php');
require_once('../header.php');
require_once('manufacturers_lib.php');
if (isset($_GET['id'])) {
    $a_contact = get_manufacturer_detail($_GET['id']);
}
if (isset($_POST['go'])) {
    update_manufacturer($_POST);
}
?>

<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
<?php require_once('../left_menu.php'); ?>
    <!-- END SIDEBAR -->
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper">
        <div class="page-content">
            <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

            <!-- /.modal -->
            <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
            <!-- BEGIN STYLE CUSTOMIZER -->

            <!-- END STYLE CUSTOMIZER -->
            <!-- BEGIN PAGE HEADER-->
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->

                    <ul class="page-breadcrumb breadcrumb">

                        <li>
                            <i class="fa fa-home"></i>
                            <a href="<? echo $url ;?>/dashboard.php">
                                Trang chủ
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        <li>
                            <a href="<? echo $url ;?>/manufacturer/manufacturers.php">
                                Danh sách công ty
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        <li>
                            <a href="add_manufacturer.php">
                                Tạo mới
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>

                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-reorder"></i>Form nhập liệu
                    </div>

                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form id ='form_add_manufacturer' class="horizontal-form" method="post" action="edit_manufacturer_detail.php">
                        <div class="form-body">
                            <h3 class="form-section">Thông tin công ty</h3>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Tên công ty
                                            <span class="required">*</span>
                                        </label>
                                        <input type="text" class="form-control" value="<?php echo (isset($a_contact['manufacturer_name']) ? $a_contact['manufacturer_name'] : '') ?>" id="manufacturer_name" name="manufacturer_name">
                                        <input type="hidden" name="id" value="<?php echo (isset($a_contact['id']) ? $a_contact['id'] : '') ?>"/>
                                    </div>
                                </div>
                                <!--/span-->
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Website

                                        </label>
                                        <input type="text" value="<?php echo (isset($a_contact['website']) ? $a_contact['website'] : '') ?>"  class="form-control" id="website" name="website">

                                    </div>
                                </div>
                                <!--/span-->
                            </div>
                            <!--/row-->
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Lĩnh vực hoạt động</label>
                                        <select name="industry" tabindex="" class="form-control">
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == '--None--') ? 'selected="selected"' : '') ?> value="--None--">
                                                --Chưa chọn--
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Apparel') ? 'selected="selected"' : '') ?> value="Apparel">
                                                Trang sức
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Banking') ? 'selected="selected"' : '') ?> value="Banking">
                                                Ngân hàng
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Biotechnology') ? 'selected="selected"' : '') ?> value="Biotechnology">
                                                Công nghệ sinh học
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Chemicals') ? 'selected="selected"' : '') ?> value="Chemicals">
                                                Hóa chất
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Communications') ? 'selected="selected"' : '') ?> value="Communications">
                                                Thông tin liên lạc
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Construction') ? 'selected="selected"' : '') ?> value="Construction">
                                                Xây dựng
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Consulting') ? 'selected="selected"' : '') ?> value="Consulting">
                                                Tư vấn
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Education') ? 'selected="selected"' : '') ?> value="Education">
                                                Giáo dục
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Electronics') ? 'selected="selected"' : '') ?> value="Electronics">
                                                Điện
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Energy') ? 'selected="selected"' : '') ?> value="Energy">
                                                Năng lượng
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Engineering') ? 'selected="selected"' : '') ?> value="Engineering">
                                                Kỹ sư
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Entertainment') ? 'selected="selected"' : '') ?> value="Entertainment">
                                                Hoạt động giải trí
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Environmental') ? 'selected="selected"' : '') ?> value="Environmental">
                                                Môi trường
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Finance') ? 'selected="selected"' : '') ?> value="Finance">
                                                Tài chính
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Food & Beverage') ? 'selected="selected"' : '') ?> value="Food & Beverage">
                                                Thực phẩm
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Government') ? 'selected="selected"' : '') ?> value="Government">
                                                Chính phủ
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Healthcare') ? 'selected="selected"' : '') ?> value="Healthcare">
                                                Chăm sóc sức khỏe
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Hospitality') ? 'selected="selected"' : '') ?> value="Hospitality">
                                                Y tế
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Insurance') ? 'selected="selected"' : '') ?> value="Insurance">
                                                Bảo hiểm
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Machinery') ? 'selected="selected"' : '') ?> value="Machinery">
                                                Cơ khí
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Manufacturing') ? 'selected="selected"' : '') ?> value="Manufacturing">
                                                Sản xuất
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Media') ? 'selected="selected"' : '') ?> value="Media">
                                                Phương tiện truyền thông
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Not For Profit') ? 'selected="selected"' : '') ?> value="Not For Profit">
                                                Phi lợi nhuận
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Recreation') ? 'selected="selected"' : '') ?> value="Recreation">
                                                Khu giải trí
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Retail') ? 'selected="selected"' : '') ?> value="Retail">
                                                Đại lý bán lẻ
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Shipping') ? 'selected="selected"' : '') ?> value="Shipping">
                                                Vận tải đường thủy
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Technology') ? 'selected="selected"' : '') ?> value="Technology">
                                                Công nghệ
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Telecommunications') ? 'selected="selected"' : '') ?> value="Telecommunications">
                                                Viễn thông
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Transportation') ? 'selected="selected"' : '') ?> value="Transportation">
                                                Vận tải
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Utilities') ? 'selected="selected"' : '') ?> value="Utilities">
                                                Phục vụ cộng đồng
                                            </option>
                                            <option <?php echo ((isset($a_contact) && $a_contact['industry'] == 'Other') ? 'selected="selected"' : '') ?> value="Other">
                                                Khác
                                            </option>
                                        </select>

                                    </div>
                                </div>
                                <!--/span-->
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Fax</label>
                                        <input type="text" value="<?php echo (isset($a_contact['fax']) ? $a_contact['fax'] : '') ?>" name="fax" class="form-control">
                                    </div>
                                </div>
                                <!--/span-->
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label">Email</label>
                                        <input type="text" value="<?php echo (isset($a_contact['email']) ? $a_contact['email'] : '') ?>" name="email" class="form-control">

                                    </div>
                                </div>
                                <!--/span-->
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="control-label">Số điện thoại 1</label>
                                        <input type="text" value="<?php echo (isset($a_contact['phone1']) ? $a_contact['phone1'] : '') ?>" name="phone1" class="form-control">
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="control-label">Số điện thoại 2</label>
                                        <input type="text" value="<?php echo (isset($a_contact['phone2']) ? $a_contact['phone2'] : '') ?>" name="phone2" class="form-control">
                                    </div>
                                </div>
                                <!--/span-->
                            </div>
                            <!--/row-->

                            <!--/row-->
                            <h3 class="form-section">Địa chỉ hóa đơn</h3>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">

                                        <textarea name="billing_address" rows="3" class="form-control">
<?php echo (isset($a_contact['billing_address']) ? $a_contact['billing_address'] : '') ?>
                                        </textarea>
                                    </div>
                                </div>

                            </div>

                            <!--/row-->

                            <!--/row-->
                            <h3 class="form-section">Địa chỉ nhận hàng</h3>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">

                                        <textarea name="shipping_address" rows="3" class="form-control">
<?php echo (isset($a_contact['shipping_address']) ? $a_contact['shipping_address'] : '') ?>
                                        </textarea>
                                    </div>
                                </div>

                            </div>

                            <!--/row-->

                            <!--/row-->
                            <h3 class="form-section">Mô tả chung</h3>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">

                                        <textarea name="description" rows="3" class="form-control">
<?php echo (isset($a_contact['description']) ? $a_contact['description'] : '') ?>
                                        </textarea>
                                    </div>
                                </div>

                            </div>

                            <!--/row-->

                        </div>
                        <div class="form-actions right">
                            <button class="btn default" type="button">Hủy</button>
                            <button class="btn blue" type="submit" name="go"><i class="fa fa-check"></i> Lưu</button>
                        </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
            <a class="btn default" id="auto_fire_when_add_ok">

            </a>
            <!-- END PAGE CONTENT -->
        </div>
    </div>
    <!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<?php
require_once('../footer.php');
require_once('../common_script.php');
?>
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="<?php echo $url ?>/assets/scripts/core/app.js"></script>
<script src="<?php echo $url ?>/js/add_manufacturer_validation.js"></script>
<script src="<?php echo $url ?>/js/add_manufacturer_alert_dialog.js"></script>
<script>
    jQuery(document).ready(function () {
        // initiate layout and plugins
        App.init();
        FormAddContactValidation.init();
        UIAlertDialogApi.init();
<?php
if (isset($_POST['go'])) {
    ?>
            $('#auto_fire_when_add_ok').click();

    <?php
}
?>
    });
</script>
</body>
<!-- END BODY -->
</html>